package com.magenta.maxoptra.gis;

import static com.magenta.maxoptra.gis.GISFieldType.*;

/**
 * Created by user on 24.03.14.
 */
public enum PtvMapAttribute implements GISAccountProperty {

    PTVbaseServerIp(GisParameter.server_ip, MapProviderType.ptv, TEXT, "192.0.2.37", true, 1L,true),
    PTVWsdlLocation(GisParameter.wsdl_location, MapProviderType.ptv, TEXT, "http://192.0.2.37:50030/xroute/ws/XRoute", true, 2L,true),
    PTVUseShortestRoute(GisParameter.use_shortest_route, MapProviderType.ptv, BOOLEAN, "true", true, 5L,true),
    PtvEnableCache(GisParameter.enableCache, MapProviderType.ptv, GISFieldType.BOOLEAN, "true", true, 2L, true),
    PtvCacheStorageTime(GisParameter.cacheStorageTime, MapProviderType.ptv, GISFieldType.INTEGER, "30", true, 3L, true),
    PtvRoutesBatchSizeForDistanceCalculation(GisParameter.routes_batch_size_for_distance_calculation, MapProviderType.ptv, GISFieldType.INTEGER, "50", true, 4L, true),
    PtvPersistedCacheMessageSize(GisParameter.persisted_cache_message_size, MapProviderType.ptv, INTEGER, "100", true, 5L, true),
    PtvAttemptsCountForBatchDistanceCalculation(GisParameter.attempts_count_for_batch_distance_calculation, MapProviderType.ptv, INTEGER, "3", false, 6L, true),
    PtvEnableLog(GisParameter.enableLogging, MapProviderType.ptv, GISFieldType.BOOLEAN, "false", false, 6L, true, false),
    PtvCorrectionFactor(GisParameter.correctionFactor, MapProviderType.ptv, GISFieldType.FLOAT, "1", true, 7L, false, false);
    ;

    private String name;
    private String label;
    private String tab = "GIS";
    private Long order;
    private GISFieldType type;
    private String defaultValue;
    private boolean required;
    private String groupName;
    private boolean important = true;
    private boolean readOnly = false;

    @Override
    public String getName() {
        return name;
    }

    @Override
    public GISFieldType getType() {
        return type;
    }

    @Override
    public String getLabel() {
        return label;
    }

    @Override
    public Long getOrder() {
        return order;
    }

    @Override
    public Boolean getMandatory() {
        return required;
    }

    @Override
    public String getGroup() {
        return groupName;
    }

    @Override
    public String getTab() {
        return tab;
    }

    @Override
    public String getDefaultValue() {
        return defaultValue;
    }

    @Override
    public boolean isImportant() {
        return important;
    }

    @Override
    public boolean isReadOnly() {
        return readOnly;
    }


    private PtvMapAttribute(String name, String label, GISFieldType type, String defaultValue,
                            boolean required, String groupName, Long order, boolean important, boolean readOnly) {
        this(name, label, type, defaultValue, required, groupName, order, important);
        this.readOnly = readOnly;
    }


    private PtvMapAttribute(String name, String label, GISFieldType type, String defaultValue,
                            boolean required, String groupName, Long order, boolean important) {
        this.name = name;
        this.label = label;
        this.type = type;
        this.defaultValue = defaultValue;
        this.groupName = groupName;
        this.required = required;
        this.order = order;
        this.important = important;
    }

    private PtvMapAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                            String defaultValue, boolean required, Long order, boolean important, boolean readOnly) {
        this(parameter, providerType, type, defaultValue, required, order, important);
        this.readOnly = readOnly;
    }


    private PtvMapAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                            String defaultValue, boolean required, Long order, boolean important) {
        this(parameter.withProvider(providerType.name()),
                parameter.getLabel(),
                type,
                defaultValue,
                required,
                providerType.getLabel(),
                order, important);
    }
}
